/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package jpa.entities;

import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeSupport;
import java.io.Serializable;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Transient;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author innovapps.co
 */
@Entity
@Table(name = "malla")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Malla.findAll", query = "SELECT m FROM Malla m"),
    @NamedQuery(name = "Malla.findByIdMalla", query = "SELECT m FROM Malla m WHERE m.idMalla = :idMalla"),
    @NamedQuery(name = "Malla.findByReferencia", query = "SELECT m FROM Malla m WHERE m.referencia = :referencia"),
    @NamedQuery(name = "Malla.findByTransversal", query = "SELECT m FROM Malla m WHERE m.transversal = :transversal"),
    @NamedQuery(name = "Malla.findByLongitudinal", query = "SELECT m FROM Malla m WHERE m.longitudinal = :longitudinal"),
    @NamedQuery(name = "Malla.findByPeso", query = "SELECT m FROM Malla m WHERE m.peso = :peso"),
    @NamedQuery(name = "Malla.findByAreaNominal", query = "SELECT m FROM Malla m WHERE m.areaNominal = :areaNominal")})
public class Malla implements Serializable {
    @Transient
    private PropertyChangeSupport changeSupport = new PropertyChangeSupport(this);
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "id_malla")
    private Integer idMalla;
    @Basic(optional = false)
    @Column(name = "referencia")
    private String referencia;
    @Basic(optional = false)
    @Column(name = "transversal")
    private float transversal;
    @Basic(optional = false)
    @Column(name = "longitudinal")
    private float longitudinal;
    @Basic(optional = false)
    @Column(name = "peso")
    private float peso;
    @Basic(optional = false)
    @Column(name = "area_nominal")
    private float areaNominal;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "mallasIdMallas")
    private List<InformeSoldadura> informeSoldaduraList;

    public Malla() {
    }

    public Malla(Integer idMalla) {
        this.idMalla = idMalla;
    }

    public Malla(Integer idMalla, String referencia, float transversal, float longitudinal, float peso, float areaNominal) {
        this.idMalla = idMalla;
        this.referencia = referencia;
        this.transversal = transversal;
        this.longitudinal = longitudinal;
        this.peso = peso;
        this.areaNominal = areaNominal;
    }

    public Integer getIdMalla() {
        return idMalla;
    }

    public void setIdMalla(Integer idMalla) {
        Integer oldIdMalla = this.idMalla;
        this.idMalla = idMalla;
        changeSupport.firePropertyChange("idMalla", oldIdMalla, idMalla);
    }

    public String getReferencia() {
        return referencia;
    }

    public void setReferencia(String referencia) {
        String oldReferencia = this.referencia;
        this.referencia = referencia;
        changeSupport.firePropertyChange("referencia", oldReferencia, referencia);
    }

    public float getTransversal() {
        return transversal;
    }

    public void setTransversal(float transversal) {
        float oldTransversal = this.transversal;
        this.transversal = transversal;
        changeSupport.firePropertyChange("transversal", oldTransversal, transversal);
    }

    public float getLongitudinal() {
        return longitudinal;
    }

    public void setLongitudinal(float longitudinal) {
        float oldLongitudinal = this.longitudinal;
        this.longitudinal = longitudinal;
        changeSupport.firePropertyChange("longitudinal", oldLongitudinal, longitudinal);
    }

    public float getPeso() {
        return peso;
    }

    public void setPeso(float peso) {
        float oldPeso = this.peso;
        this.peso = peso;
        changeSupport.firePropertyChange("peso", oldPeso, peso);
    }

    public float getAreaNominal() {
        return areaNominal;
    }

    public void setAreaNominal(float areaNominal) {
        float oldAreaNominal = this.areaNominal;
        this.areaNominal = areaNominal;
        changeSupport.firePropertyChange("areaNominal", oldAreaNominal, areaNominal);
    }

    @XmlTransient
    public List<InformeSoldadura> getInformeSoldaduraList() {
        return informeSoldaduraList;
    }

    public void setInformeSoldaduraList(List<InformeSoldadura> informeSoldaduraList) {
        this.informeSoldaduraList = informeSoldaduraList;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idMalla != null ? idMalla.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Malla)) {
            return false;
        }
        Malla other = (Malla) object;
        if ((this.idMalla == null && other.idMalla != null) || (this.idMalla != null && !this.idMalla.equals(other.idMalla))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return referencia + " " + transversal + "x" + longitudinal + " " + peso;
    }

    public void addPropertyChangeListener(PropertyChangeListener listener) {
        changeSupport.addPropertyChangeListener(listener);
    }

    public void removePropertyChangeListener(PropertyChangeListener listener) {
        changeSupport.removePropertyChangeListener(listener);
    }
    
}
